import * as constants  from './constants';
import  axios from 'axios';


const changeLogin = (login) => ({
  type: constants.CHANGE_LOGIN,
  login
})

export const doLogOut = (login) => ({
  type: constants.CHANGE_LOGOUT,
  login
})

export const doLogin = (account ,password) =>{

  return (dispatch) => {
    axios.get('/api/login.json?account='+ account + "&password=" + password).then((res) => {

    const data = res.data;
    if (data.data === true){
      dispatch(changeLogin(data.data));
    }
    }).catch((error) => {

      console.log(error);
    })

  }

}
